home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / documents / OpenGL / extensions / man / glxintro.z / glxintro
Encoding:
Text File  |  1996-11-11  |  17.5 KB  |  263 lines

  1.  
  2.  
  3.  
  4. ggggllllXXXXIIIInnnnttttrrrroooo((((3333GGGG))))                OOOOppppeeeennnnGGGGLLLL RRRReeeeffffeeeerrrreeeennnncccceeee ---- GGGGLLLLXXXX                ggggllllXXXXIIIInnnnttttrrrroooo((((3333GGGG))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      ggggllllXXXXIIIInnnnttttrrrroooo - Introduction to OpenGL in the X window system
  10.  
  11.  
  12.  
  13. OOOOVVVVEEEERRRRVVVVIIIIEEEEWWWW
  14.      OpenGL is a high-performance 3-D-oriented renderer.  It is available in
  15.      the X window system through the GLX extension.  Use ggggllllXXXXQQQQuuuueeeerrrryyyyEEEExxxxtttteeeennnnssssiiiioooonnnn and
  16.      ggggllllXXXXQQQQuuuueeeerrrryyyyVVVVeeeerrrrssssiiiioooonnnn to establish whether the GLX extension is supported by an
  17.      X server, and if so, what version is supported.
  18.  
  19.      GLX extended servers make a subset of their visuals available for OpenGL
  20.      rendering.  Drawables created with these visuals can also be rendered
  21.      using the core X renderer and with the renderer of any other X extension
  22.      that is compatible with all core X visuals.
  23.  
  24.      GLX extends drawables with several buffers other than the standard color
  25.      buffer.  These buffers include back and auxiliary color buffers, a depth
  26.      buffer, a stencil buffer, and a color accumulation buffer.  Some or all
  27.      are included in each X visual that supports OpenGL.
  28.  
  29.      To render using OpenGL into an X drawable, you must first choose a visual
  30.      that defines the required OpenGL buffers.  ggggllllXXXXCCCChhhhoooooooosssseeeeVVVViiiissssuuuuaaaallll can be used to
  31.      simplify selecting a compatible visual.  If more control of the selection
  32.      process is required, use XXXXGGGGeeeettttVVVViiiissssuuuuaaaallllIIIInnnnffffoooo and ggggllllXXXXGGGGeeeettttCCCCoooonnnnffffiiiigggg to select among
  33.      all the available visuals.
  34.  
  35.      Use the selected visual to create both a GLX context and an X drawable.
  36.      GLX contexts are created with ggggllllXXXXCCCCrrrreeeeaaaatttteeeeCCCCoooonnnntttteeeexxxxtttt, and drawables are created
  37.      with either XXXXCCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwww or ggggllllXXXXCCCCrrrreeeeaaaatttteeeeGGGGLLLLXXXXPPPPiiiixxxxmmmmaaaapppp.  Finally, bind the
  38.      context and the drawable together using ggggllllXXXXMMMMaaaakkkkeeeeCCCCuuuurrrrrrrreeeennnntttt.  This
  39.      context/drawable pair becomes the current context and current drawable,
  40.      and it is used by all OpenGL commands until ggggllllXXXXMMMMaaaakkkkeeeeCCCCuuuurrrrrrrreeeennnntttt is called with
  41.      different arguments.
  42.  
  43.      Both core X and OpenGL commands can be used to operate on the current
  44.      drawable.  The X and OpenGL command streams are not synchronized,
  45.      however, except at explicitly created boundaries generated by calling
  46.      ggggllllXXXXWWWWaaaaiiiittttGGGGLLLL, ggggllllXXXXWWWWaaaaiiiittttXXXX, XXXXSSSSyyyynnnncccc, and ggggllllFFFFlllluuuusssshhhh.
  47.  
  48.  
  49.  
  50. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  51.      Below is the minimum code required to create an RGBA-format, OpenGL-
  52.      compatible X window and clear it to yellow.  The code is correct, but it
  53.      does not include any error checking.  Return values _d_p_y, _v_i, _c_x, _c_m_a_p,
  54.      and _w_i_n should all be tested.
  55.  
  56.         #include <GL/glx.h>
  57.         #include <GL/gl.h>
  58.         #include <unistd.h>
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. ggggllllXXXXIIIInnnnttttrrrroooo((((3333GGGG))))                OOOOppppeeeennnnGGGGLLLL RRRReeeeffffeeeerrrreeeennnncccceeee ---- GGGGLLLLXXXX                ggggllllXXXXIIIInnnnttttrrrroooo((((3333GGGG))))
  71.  
  72.  
  73.  
  74.         static int attributeList[] = { GLX_RGBA, None };
  75.  
  76.         static Bool WaitForNotify(Display *d, XEvent *e, char *arg) {
  77.             return (e->type == MapNotify) && (e->xmap.window == (Window)arg);
  78.         }
  79.  
  80.         int main(int argc, char **argv) {
  81.             Display *dpy;
  82.             XVisualInfo *vi;
  83.             Colormap cmap;
  84.             XSetWindowAttributes swa;
  85.             Window win;
  86.             GLXContext cx;
  87.             XEvent event;
  88.  
  89.             /* get a connection */
  90.             dpy = XOpenDisplay(0);
  91.  
  92.             /* get an appropriate visual */
  93.             vi = glXChooseVisual(dpy, DefaultScreen(dpy), attributeList);
  94.  
  95.             /* create a GLX context */
  96.             cx = glXCreateContext(dpy, vi, 0, GL_TRUE);
  97.  
  98.             /* create a color map */
  99.             cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen),
  100.                                    vi->visual, AllocNone);
  101.  
  102.             /* create a window */
  103.             swa.colormap = cmap;
  104.             swa.border_pixel = 0;
  105.             swa.event_mask = StructureNotifyMask;
  106.             win = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 100, 100,
  107.                                 0, vi->depth, InputOutput, vi->visual,
  108.                                 CWBorderPixel|CWColormap|CWEventMask, &swa);
  109.             XMapWindow(dpy, win);
  110.             XIfEvent(dpy, &event, WaitForNotify, (char*)win);
  111.  
  112.             /* connect the context to the window */
  113.             glXMakeCurrent(dpy, win, cx);
  114.  
  115.             /* clear the buffer */
  116.             glClearColor(1,1,0,1);
  117.             glClear(GL_COLOR_BUFFER_BIT);
  118.             glFlush();
  119.  
  120.             /* wait a while */
  121.             sleep(10);
  122.         }
  123.      OpenGL programs must be linked with the GL and X11 libraries.  (They also
  124.      require the GLU library if they use any of the routines in the OpenGL
  125.      Utilities.)  For example, to compile the program above, use the following
  126.  
  127.  
  128.                                                                         PPPPaaaaggggeeee 2222
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135. ggggllllXXXXIIIInnnnttttrrrroooo((((3333GGGG))))                OOOOppppeeeennnnGGGGLLLL RRRReeeeffffeeeerrrreeeennnncccceeee ---- GGGGLLLLXXXX                ggggllllXXXXIIIInnnnttttrrrroooo((((3333GGGG))))
  136.  
  137.  
  138.  
  139.      command line:
  140.  
  141.         cc example.c -lGL -lX11
  142.  
  143. NNNNOOOOTTTTEEEESSSS
  144.      A color map must be created and passed to XXXXCCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwww.  See the example
  145.      code above.
  146.  
  147.      A GLX context must be created and attached to an X drawable before OpenGL
  148.      commands can be executed.  OpenGL commands issued while no
  149.      context/drawable pair is current are ignored.
  150.  
  151.      Exposure events indicate that _a_l_l buffers associated with the specified
  152.      window may be damaged and should be repainted.  Although certain buffers
  153.      of some visuals on some systems may never require repainting (the depth
  154.      buffer, for example), it is incorrect to code assuming that these buffers
  155.      will not be damaged.
  156.  
  157.      GLX commands manipulate XVisualInfo structures rather than pointers to
  158.      visuals or visual IDs.  XVisualInfo structures contain _v_i_s_u_a_l, _v_i_s_u_a_l_I_D,
  159.      _s_c_r_e_e_n, and _d_e_p_t_h elements, as well as other X-specific information.
  160.  
  161.  
  162. GGGGLLLLXXXX EEEEXXXXTTTTEEEENNNNSSSSIIIIOOOONNNNSSSS
  163.      The SSSSGGGGIIII____vvvviiiiddddeeeeoooo____ssssyyyynnnncccc extension provides a means for synchronization with
  164.      the video frame rate of a monitor--or, in the case of an interlaced moni-
  165.      tor, with the field rate of the monitor. (For more information see:
  166.      ggggllllXXXXGGGGeeeettttVVVViiiiddddeeeeooooSSSSyyyynnnnccccSSSSGGGGIIII, ggggllllXXXXWWWWaaaaiiiittttVVVViiiiddddeeeeooooSSSSyyyynnnnccccSSSSGGGGIIII).
  167.  
  168.      The SSSSGGGGIIII____sssswwwwaaaapppp____ccccoooonnnnttttrrrroooollll extension provides new parameters that modify the
  169.      semantics of ggggllllXXXXSSSSwwwwaaaappppBBBBuuuuffffffffeeeerrrrssss. With this extension an application can
  170.      specify a minimum periodicity for color buffer swaps, measured in display
  171.      retrace periods.  For more information see ggggllllXXXXSSSSwwwwaaaappppIIIInnnntttteeeerrrrvvvvaaaallllSSSSGGGGIIII.
  172.  
  173.  
  174. GGGGLLLLXXXX RRRREEEEAAAALLLLIIIITTTTYYYY EEEENNNNGGGGIIIINNNNEEEE EEEEXXXXTTTTEEEENNNNSSSSIIIIOOOONNNNSSSS
  175.      The SSSSGGGGIIIISSSS____mmmmuuuullllttttiiiissssaaaammmmpppplllleeee extension provides a mechanism to antialias all
  176.      primitives. (This extension is described in more detail in ggggllllIIIInnnnttttrrrroooo.) In
  177.      order to support multisampling both GLX and OpenGL had to be extended.
  178.      The GLX portion of the extension, designated as SSSSGGGGIIIISSSS____mmmmuuuullllttttiiiissssaaaammmmpppplllleeee,
  179.      includes new visual attributes which can be specified when calling
  180.      ggggllllXXXXCCCChhhhoooooooosssseeeeVVVViiiissssuuuuaaaallll and ggggllllXXXXGGGGeeeettttCCCCoooonnnnffffiiiigggg.
  181.  
  182.      The SSSSGGGGIIII____mmmmaaaakkkkeeee____ccccuuuurrrrrrrreeeennnntttt____rrrreeeeaaaadddd extension allows OpenGL pixel operations to
  183.      read pixel data from the buffers of one drawable and draw into the
  184.      buffers of another.  For example, pixels can be copied from one window
  185.      into another, or from a GLXPbuffer into a window.  For more information
  186.      see ggggllllXXXXMMMMaaaakkkkeeeeCCCCuuuurrrrrrrreeeennnnttttRRRReeeeaaaaddddSSSSGGGGIIII and ggggllllXXXXGGGGeeeettttCCCCuuuurrrrrrrreeeennnnttttRRRReeeeaaaaddddDDDDrrrraaaawwwwaaaabbbblllleeeeSSSSGGGGIIII.
  187.  
  188.      The SSSSGGGGIIIIXXXX____vvvviiiiddddeeeeoooo____ssssoooouuuurrrrcccceeee extension allows pixel data to be sourced from a
  189.      video input stream.  It defines a new type of drawable,
  190.  
  191.  
  192.                                                                         PPPPaaaaggggeeee 3333
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199. ggggllllXXXXIIIInnnnttttrrrroooo((((3333GGGG))))                OOOOppppeeeennnnGGGGLLLL RRRReeeeffffeeeerrrreeeennnncccceeee ---- GGGGLLLLXXXX                ggggllllXXXXIIIInnnnttttrrrroooo((((3333GGGG))))
  200.  
  201.  
  202.  
  203.      GLXVideoSourceSGIX, that represents the drain node of a Video Library
  204.      (VL) path.  A GLXVideoSourceSGIX may be passed as a parameter to
  205.      ggggllllXXXXMMMMaaaakkkkeeeeCCCCuuuurrrrrrrreeeennnnttttRRRReeeeaaaaddddSSSSGGGGIIII to indicate that pixel data should be read from the
  206.      specified video source instead of from the framebuffer.  For more infor-
  207.      mation, see ggggllllXXXXCCCCrrrreeeeaaaatttteeeeGGGGLLLLXXXXVVVViiiiddddeeeeooooSSSSoooouuuurrrrcccceeeeSSSSGGGGIIIIXXXX and ggggllllXXXXDDDDeeeessssttttrrrrooooyyyyGGGGLLLLXXXXVVVViiiiddddeeeeooooSSSSoooouuuurrrrcccceeeeSSSSGGGGIIIIXXXX.
  208.  
  209.  
  210. UUUUSSSSIIIINNNNGGGG GGGGLLLLXXXX EEEEXXXXTTTTEEEENNNNSSSSIIIIOOOONNNNSSSS
  211.      Procedure names and tokens for GLX extensions are either suffixed with
  212.      EXT, SGI, SGIS or SGIX. The meaning of these suffixes is described in
  213.      ggggllllIIIInnnnttttrrrroooo.
  214.  
  215.      All supported GLX extensions will have a corresponding definition in
  216.      glx.h and a token in the extension string returned by ggggllllXXXXQQQQuuuueeeerrrryyyyEEEExxxxtttteeeennnnssssiiiioooonnnnssss----
  217.      SSSSttttrrrriiiinnnngggg. For example, if the SSSSGGGGIIII____vvvviiiiddddeeeeoooo____ssssyyyynnnncccc extension is supported then
  218.      this token will be defined in glx.h and SSSSGGGGIIII____vvvviiiiddddeeeeoooo____ssssyyyynnnncccc will appear in the
  219.      extension string returned by ggggllllXXXXQQQQuuuueeeerrrryyyyEEEExxxxtttteeeennnnssssiiiioooonnnnssssSSSSttttrrrriiiinnnngggg. The definitions in
  220.      glx.h can be used at compile time to determine if procedure calls
  221.      corresponding to an extension exist in the library. However, extensions
  222.      which are defined in glx.h might not be implemented on all SGI platforms.
  223.  
  224.      OpenGL also has been extended. Refer to ggggllllIIIInnnnttttrrrroooo for more information.
  225.  
  226.  
  227. GGGGLLLLXXXX 1111....1111
  228.      SGI now supports GLX 1.1: this is backwards compatible with GLX 1.0 and
  229.      corresponds to OpenGL version 1.0. Call ggggllllXXXXQQQQuuuueeeerrrryyyyVVVVeeeerrrrssssiiiioooonnnn to determine at
  230.      runtime what version of GLX is being used. (If you are doing remote
  231.      rendering, GLX version 1.1 will only be used if both the client and
  232.      server can support it. This allows GLX 1.1 clients and servers to commun-
  233.      icate with GLX 1.0 clients and servers.)  You can also check the GLX ver-
  234.      sion at compile time: GLX_VERSION_1_1 will be defined in glx.h if GLX 1.1
  235.      calls are supported.
  236.  
  237.      The following new calls were introduced in GLX 1.1: ggggllllXXXXQQQQuuuueeeerrrryyyyEEEExxxxtttteeeennnnssssiiiioooonnnnssss----
  238.      SSSSttttrrrriiiinnnngggg, ggggllllXXXXQQQQuuuueeeerrrryyyySSSSeeeerrrrvvvveeeerrrrSSSSttttrrrriiiinnnngggg, and ggggllllXXXXGGGGeeeettttCCCClllliiiieeeennnnttttSSSSttttrrrriiiinnnngggg.
  239.  
  240.  
  241.  
  242. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  243.      ggggllllFFFFiiiinnnniiiisssshhhh, ggggllllFFFFlllluuuusssshhhh, ggggllllXXXXCCCChhhhoooooooosssseeeeVVVViiiissssuuuuaaaallll, ggggllllXXXXCCCCooooppppyyyyCCCCoooonnnntttteeeexxxxtttt, ggggllllXXXXCCCCrrrreeeeaaaatttteeeeCCCCoooonnnntttteeeexxxxtttt,
  244.      ggggllllXXXXCCCCrrrreeeeaaaatttteeeeGGGGLLLLXXXXPPPPiiiixxxxmmmmaaaapppp, ggggllllXXXXCCCCrrrreeeeaaaatttteeeeGGGGLLLLXXXXVVVViiiiddddeeeeooooSSSSoooouuuurrrrcccceeeeSSSSGGGGIIIIXXXX, ggggllllXXXXDDDDeeeessssttttrrrrooooyyyyCCCCoooonnnntttteeeexxxxtttt,
  245.      ggggllllXXXXGGGGeeeettttCCCClllliiiieeeennnnttttSSSSttttrrrriiiinnnngggg, ggggllllXXXXGGGGeeeettttCCCCoooonnnnffffiiiigggg, ggggllllXXXXIIIIssssDDDDiiiirrrreeeecccctttt, ggggllllXXXXMMMMaaaakkkkeeeeCCCCuuuurrrrrrrreeeennnntttt,
  246.      ggggllllXXXXMMMMaaaakkkkeeeeCCCCuuuurrrrrrrreeeennnnttttRRRReeeeaaaaddddSSSSGGGGIIII, ggggllllXXXXQQQQuuuueeeerrrryyyyEEEExxxxtttteeeennnnssssiiiioooonnnn, ggggllllXXXXQQQQuuuueeeerrrryyyyEEEExxxxtttteeeennnnssssiiiioooonnnnssssSSSSttttrrrriiiinnnngggg,
  247.      ggggllllXXXXQQQQuuuueeeerrrryyyySSSSeeeerrrrvvvveeeerrrrSSSSttttrrrriiiinnnngggg, ggggllllXXXXQQQQuuuueeeerrrryyyyVVVVeeeerrrrssssiiiioooonnnn, ggggllllXXXXSSSSwwwwaaaappppBBBBuuuuffffffffeeeerrrrssss, ggggllllXXXXUUUUsssseeeeXXXXFFFFoooonnnntttt,
  248.      ggggllllXXXXWWWWaaaaiiiittttGGGGLLLL, ggggllllXXXXWWWWaaaaiiiittttXXXX, XXXXCCCCrrrreeeeaaaatttteeeeCCCCoooolllloooorrrrmmmmaaaapppp, XXXXCCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwww, XXXXSSSSyyyynnnncccc
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.                                                                         PPPPaaaaggggeeee 4444
  259.  
  260.  
  261.  
  262.